module game{
    export class CoreMediator extends BaseController{
        private $panel:CoreView;
        constructor(){
            super();
            //ui
            this.$panel = new CoreView(this,App.UI_Main);
            App.ViewManager.register(ViewConst.Core,this.$panel);


             this.registerFunc(EventConst.Remove_Candy, this.onClickCandy, this);
             this.registerFunc(EventConst.Item_Num_Updata,this.updataItems,this);
        }

        private onClickCandy(vo){
            if(gameData.isHammaring){
                //敲碎一块
                this.$panel.saveVersion();
                // gameData.hammarNum -= 1;
                gameData.removeHammarItem();
                gameData.hammarCount -= 1;
                gameData.isHammaring = false;
                this.$panel.hammarCandy(vo);
                return;
            }

            // if(gameData.isReseting){
            //     //悔棋
            //     if(gameData.preMapDic.length <= 0) return;
            //     gameData.resetNum -= 1;
            //     gameData.resetCount -= 1;
            //     gameData.isReseting = false;
            //     this.$panel.resetMap();
            //     return;
            // }
            this.$panel.saveVersion();
            this.$panel.removeCandy(vo);
            console.log(gameData.preMapDic);
        }

        private updataItems()
        {
            this.$panel.txt_hammar.text = gameData.getAllHammar() + "";
            this.$panel.txt_reset.text = gameData.getAllReset() + "";
        }        
    }
}